package rs.frenjoynet.music.core;

import rs.frenjoynet.core.core.BaseFacadeImpl;
import rs.frenjoynet.core.core.db.DBBroker;
import rs.frenjoynet.core.core.db.MySqlHibDBBrokerImpl;
import rs.frenjoynet.music.core.entity.primerEntiteta;
import rs.frenjoynet.music.core.entity.Album;

import javax.ejb.Stateful;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * Created by IntelliJ IDEA.
 * User: ppopovic
 * Date: 27.10.2009.
 * Time: 11.14.03
 * To change this template use File | Settings | File Templates.
 */
@Stateful
public class MusicFacadeBean extends BaseFacadeImpl implements MusicFacade
{
	private static final String configurationPath = "rs/frenjoynet/music/core/cfg/musHibernate.cfg.xml";
	private DBBroker dbBroker;

	primerEntiteta us = new primerEntiteta("petar popovic");


	@Override
	public Album create(Album entitet)
	{
		return (Album)getDBBroker().insert(Album.class, entitet);
	}

	private DBBroker getDBBroker()
	{
		if (dbBroker == null)
		{
			SessionFactory sessionFactory = new Configuration().configure(configurationPath).buildSessionFactory();

			DBBroker dbBroker = new MySqlHibDBBrokerImpl(sessionFactory);
		}
		return  dbBroker;
	}

	@Override
	public String getResponse()
	{
		return "responseee Ejb";
	}
}
